package com.gugee.ins.common.dal.service.blogger;

import com.baomidou.mybatisplus.extension.service.IService;
import com.gugee.ins.common.model.ai.InComeRequest;
import com.gugee.ins.common.model.ai.InComeResponse;
import com.gugee.ins.common.model.ai.InsBloggerCategory;
import com.gugee.ins.common.model.ai.InsBloggerLanguage;
import com.gugee.ins.common.model.mysql.blogger.InsBlogger;
import com.gugee.ins.common.model.mysql.blogger.InsBloggerMain;
import com.gugee.ins.common.model.spider.blogger.InsBloggerUserFromId;
import com.gugee.ins.data.common.msg.InsBloggerMessage;

import java.util.List;

/**
 * insBlogger dao
 * @author Huangxin
 */
public interface InsBloggerMainDao extends IService<InsBloggerMain> {
    long getMaxId();
    List<InsBloggerMessage> findInsBloggerMessageByPages(long startId, long endId);
    List<InsBloggerMessage> findInsBloggerMessageByPages(long startId, long endId,long followerCount,long lastCollectTime);
    List<InsBloggerMessage> findInsBloggerMessageByPages(long startId, long endId ,long followerCount);

    List<InsBloggerMessage> findInsBloggerMessageByRealFollowerStTime(long startId,long endId,long followerCount,long limitTime);

    List<InsBloggerMessage> findInsBloggerMessageByLastGenderStTime(long startId,long endId,long followerCount,long limitTime);

    /**
     * 更新播主的基本信息，数据来自uid接口
     * @param insBloggerUserFromId 来自uid接口
     */
    int updateMBlogger(InsBloggerUserFromId insBloggerUserFromId);

    /**
     * 根据uid查找数据
     * @param uid
     * @return
     */
    InsBloggerMain findByUid(long uid);

    /**
     * 将blogger表中存在，而blogger_main中不存在，且满足followerCount大小的uidS相关播主查询出来，构造成InsBloggerMain列表
     * @param uids uid
     * @param followerCount 粉丝数
     * @return
     */
    List<InsBloggerMain> produceInsBloggerMainsFromBlogger(List<Long> uidS,int followerCount);
    void batchInsertBloggerMains(List<InsBloggerMain> insBloggerMainList);
    List<InsBloggerMain> findInUid(List<Long> uids);


    /**
     * 统计同量级大博主真实粉丝占比平均率
     * @param category
     * @param followerStart
     * @param followerEnd
     * @return
     */
    double stBMAvgRealFollowerRateByCategoryAndFollower(String category,int followerStart,int followerEnd);


    /**
     * 统计同量级大博主粉丝增长平均率
     * @param category
     * @param followerStart
     * @param followerEnd
     * @return
     */
    double stBMAvgFollowerGrowRateByCategoryAndFollower(String category, int followerStart, int followerEnd);

    /**
     * 统计同量级大博主广告帖子参与率
     * @param category
     * @param followerStart
     * @param followerEnd
     * @return
     */
    double stBMSumMediaErByCategoryAndFollower(String category,int followerStart,int followerEnd,long timeRang,Boolean isAd);

    /**
     * 同量级大博主个数
     * @param category
     * @param followerStart
     * @param followerEnd
     * @return
     */
    long countByCategoryAndFollower(String category,int followerStart,int followerEnd);

     void collectMBlogger(List<Long> uidS,int followerCount,long createTime);

    /**
     * 根据uid条件更新
     * @param insBloggerMain 数据
     * @return
     */
    void updateByUidSelective(InsBloggerMain insBloggerMain);

    /**
     * 根据uid 更新年龄和性别
     * @param age
     * @param gender
     * @param birth
     * @param race
     * @param uid
     */
    void updateAiGenderAndAiAgeByUid(int age,int gender,int birth,String race,long uid);

    /**
     * 根据uid 更新国家
     * @param uid
     * @param nation
     * @param nationSource
     */
    void updateNation(long uid,String nation,int nationSource);

    /**
     * 根据uid 更新语言
     * @param uid
     * @param language
     */
    void updateLanguage(long uid,String language);

    /**
     * 批量更新 语言
     * @param insBloggerLanguages
     */
    void batchUpdateLanguage(List<InsBloggerLanguage> insBloggerLanguages);

    /**
     * 根据uids 更新 近30天粉丝增长数和粉丝增长率
     * @param uids
     * @param dateCode
     */
    void updateLastFollowerGrowByUids(List<Long> uids,int dateCode);

    /**
     * 根据id分页查询uid
     * @param startId
     * @param endId
     * @param followerCount
     * @return
     */
    List<Long> findInsBloggerUidByPages(long startId, long endId ,long followerCount);

    /**
     * 更新帖子采集时间
     * @param uid
     */
    void updateMediaCollectTime(long uid);

    /**
     * 更新帖子平均参与率
     * @param uid
     * @param timeRang
     */
    void updateAvgEr(long uid,long timeRang);

    /**
     * 更新评论采集
     * @param uid
     * @param commentCollectCount
     */
    void updateCommentCollectTime(long uid,int commentCollectCount);

    /**
     * 更新粉丝列表采集时间
     * @param uid
     */
    void updateFollowerCollectTime(long uid);

    /**
     * 更新博主广告帖子平均ER值
     * @param uid
     * @param brandMediaEr
     */
    void updateBrandMediaEr(long uid, double brandMediaEr);

    /**
     * 获取需要采集帖子的播主消息数据
     * @param startId
     * @param endId
     * @param followerCount
     * @param mediaMinCount
     * @param lastMediaCollectTime
     * @return
     */
    List<InsBloggerMessage> findInsMediaCollectMessageByPages(long startId, long endId,long followerCount,int mediaMinCount,
                                                                     long lastMediaCollectTime);

    /**
     * 获取需要采集评论的播主消息数据
     * @param startId
     * @param endId
     * @param followerCount
     * @param lastCommentCollectTime
     * @return
     */
    List<InsBloggerMessage> findInsCommentCollectMessageByPages(long startId, long endId,long followerCount,
                                                              long lastCommentCollectTime);

    /**
     * 获取需要采集活跃粉丝的播主消息数据
     * @param startId
     * @param endId
     * @param followerCount
     * @param lastFollowerCollectTime
     * @return
     */
    List<InsBloggerMessage> findInsBloggerFollowerCollectMessageByPages(long startId, long endId,long followerCount,
                                                                long lastFollowerCollectTime);

    /**
     * 获取需要分析的帖子消息
     * @param startId
     * @param endId
     * @param followerCount
     * @param mediaMinCount
     * @return
     */
    List<InsBloggerMessage> findAdMediaIdentifyByPages(long startId, long endId, long followerCount,
                                                     int mediaMinCount);

    /**
     * 获取需要采集地理位置的播主消息数据
     * @param startId
     * @param endId
     * @param followerCount
     * @return
     */
    List<InsBloggerMessage> findInsLocationCollectMessageByPages(long startId, long endId,long followerCount);

    /**
     * 获取需要采集地理位置的大播主活跃粉丝消息数据
     * @param uid
     * @param limitTime
     * @return
     */
    List<InsBlogger> findInsLocationCollectMessageByUid(long uid, long limitTime);

    /**
     * 获取需要采集关注的播主消息数据
     * @param startId
     * @param endId
     * @param followerCount
     * @return
     */
    List<InsBloggerMessage> findInsBloggerFollowingCollectMessageByPages(long startId, long endId,long followerCount);

    /**
     * 获取需要采集关注的大播主活跃粉丝消息数据
     * @param uid
     * @param limitTime
     * @param followingMinCount
     * @param limitCount
     * @return
     */
    List<InsBloggerMessage> findInsBloggerFollowingCollectMessageByUid(long uid,long limitTime,int followingMinCount,int limitCount);

    /**
     * 获取需要分析头像的播主消息数据
     * @param startId
     * @param endId
     * @param followerCount
     * @return
     */
    List<InsBloggerMessage> findInsAnalysisAvatarMessageByPages(long startId, long endId,long followerCount);

    /**
     * 获取需要分析头像的大播主活跃粉丝消息数据
     * @param uid
     * @param limitTime
     * @return
     */
    List<InsBloggerMessage> findInsAnalysisAvatarMessageByUid(long uid,long limitTime);

    /**
     * 获取需要分析语言的播主消息数据
     * @param startId
     * @param endId
     * @param followerCount
     * @return
     */
    List<InsBloggerMessage> findInsAnalysisLanguageMessageByPages(long startId, long endId,long followerCount);

    /**
     * 获取需要分析国家的播主消息数据
     * @param startId
     * @param endId
     * @param followerCount
     * @return
     */
    List<InsBloggerMessage> findInsAnalysisNationMessageByPages(long startId, long endId,long followerCount);

    /**
     * 获取需要分析国家的的大播主活跃粉丝消息数据
     * @param uid
     * @param limitTime
     * @return
     */
    List<InsBloggerMessage> findInsAnalysisNationMessageByUid(long uid,long limitTime);

    /**
     * 获取需要分析收入的播主消息数据
     * @param startId
     * @param endId
     * @param followerCount
     * @return
     */
    List<InsBloggerMessage> findInsAnalysisIncomeMessageByPages(long startId, long endId,long followerCount);

    /**
     * 获取指定的粉丝量级id信息
     * @param idLimit
     * @return
     */
    List<Integer> findFollowerSizeIdByLimitId(int idLimit);

    /**
     * 获取同分类同量级的播主总数
     * @param category
     * @param followerSize
     * @return
     */
    int findTotalCountByCategoryAndFollowerSize(String category,int followerSize);

    /**
     * 更新真实粉丝占比率
     * @param id
     * @param realFollowerRate
     */
    void updateRealFollowerRate(long id,double realFollowerRate);

    /**
     * 获取需要分析收入的大播主活跃粉丝消息数据
     * @param uid
     * @param limitTime
     * @return
     */
    List<InComeRequest> findInsAnalysisIncomeByUid(long uid, long limitTime);

    /**
     * 获取需要分析收入的大播主消息数据
     * @param uid
     * @return
     */
    List<InComeRequest> findMInsAnalysisIncomeByUid(long uid);

    /**
     * 批量更新ai收入
     * @param inComeResponses
     */
    void batchUpdateIncome(List<InComeResponse> inComeResponses);

    /**
     * 更新活跃粉丝的统计时间字段
     * @param insBloggerMain
     */
    void updateStActiveFollowerTime(InsBloggerMain insBloggerMain);

    /**
     * 更新播主平均点赞数和平均评论数
     * @param uid
     * @param limitTime
     */
    void updateMediaAvg(long uid,long limitTime);

    /**
     * 批量更新ai分类
     * @param insBloggerCategories
     */
    void batchUpdateAiCategory(List<InsBloggerCategory> insBloggerCategories);

    /**
     * 根据给定的uid 查找出未进行播主分类的uid
     * @param insBloggerMessages
     * @return
     */
    List<Long> findEmptyCategoryByUid(List<InsBloggerMessage> insBloggerMessages);

    /**
     * 获取需要分析分类的播主消息数据
     * @param startId
     * @param endId
     * @param followerCount
     * @param limitTime
     * @return
     */
    List<InsBloggerMessage> findInsAnalysisCategoryMessageByPages(long startId, long endId,long followerCount,long limitTime);

    /**
     * 更新最近分析播主分类的时间
     * @param uid
     */
    void updateLastAnalysisCategoryTime(long uid);

    /**
     * 获取需要更新数据的掉分的大播主消息数据
     * @param startId
     * @param endId
     * @param followerCount
     * @param limitTime
     * @return
     */
    List<InsBloggerMessage> findUpdateLowFollowerMBloggerMsgByPages(long startId, long endId,long followerCount,long limitTime);

    /**
     * 更新状态
     * @param uid
     * @param status
     */
    void updateAccountStatus(long uid ,int status);

    /**
     * 查看是否存在
     * @param uid
     * @return
     */
    boolean findExist(long uid);

    /**
     * 获取需要更新数据的中播主消息数据
     * @param startId
     * @param endId
     * @param mainBloggerFollowerCount
     * @param bigBloggerFollowerCount
     * @param limitTime
     * @return
     */
    List<InsBloggerMessage> findUpdateMiddleBloggerMsgByPages(long startId, long endId,long mainBloggerFollowerCount,
                                                              long bigBloggerFollowerCount,long limitTime);
    /**
     * 获取需要采集帖子的中播主消息数据
     * @param startId
     * @param endId
     * @param mainBloggerFollowerCount
     * @param bigBloggerFollowerCount
     * @param mediaMinCount
     * @param lastMediaCollectTime
     * @return
     */
    List<InsBloggerMessage> findInsMiddleBgMediaCollectMessageByPages(long startId, long endId,long mainBloggerFollowerCount,
                                                                      long bigBloggerFollowerCount,int mediaMinCount,
                                                                      long lastMediaCollectTime);

    /**
     * 查询需要分析品牌的播主信息
     * @param startId
     * @param endId
     * @param limitTime
     * @return
     */
    List<InsBloggerMessage> findAnalysisBrandBloggerByPages(long startId, long endId,long limitTime);

    /**
     * 更新最近分析品牌的标记字段
     * @param uid
     * @param brandJson
     */
    void updateAiBrand(long uid,String brandJson);

    /**
     * 根据uid 获取 userName
     * @param uids
     * @return
     */
    List<String> findUserNameByUid(List<Long> uids);
}
